* GENERAL INFO
	* Project: Red/Blue Workshop and Depolarization
 
* DO FILE INFO
	* Cleans the raw baseline data (all campuses)
	* Variable construction
	* ssc install avg_effect 
	* ssc install estout
	* net install dm74.pkg

*********************************************************************************************************************


/* SETUP */

			clear
			set more off
			capture cd "~/Dropbox/Projects/Better Angels RCT/10_Analysis/03_Code/Replication/Final"

			use "baseline_raw_all.dta"
			
/* VAR CLEANING */

			* POLITICAL ENGAGEMENT 
			
			gen talk_politics=q32
				destring talk_politics, replace
				replace talk_politics = 5-talk_politics
				la def talk_politics 4 "Nearly everyday" 3 "A few times a week" 2 "A few times a month" 1 "Less than monthly"
				la val talk_politics talk_politics
				la var talk_politics "Talk politics"

			gen follow_politics=q33
				destring follow_politics, replace
				replace follow_politics = 5-follow_politics
				la def follow_politics 4 "Very closely" 3 "Somewhat closely" 2 "Not very closely" 1 "Not at all"
				la val follow_politics follow_politics
				la var follow_politics "Follow politics"
				
			gen plan_vote=(q34=="1") if q34!=""
				la var plan_vote "Plan to vote 2020"
				
			gen attend_rally=q351_1
				la var attend_rally "Attended rally past yr"
			gen volunteer=q351_2
				la var volunteer "Worked campaign past yr"
			gen donate_money=q351_3
				la var donate_money "Donated money party/campaign past yr"	
			gen member_group=q351_4
				la var member_group "Member political group past yr"
			gen contact_official=q351_5
				la var contact_official "Contacted elected official past yr"
			gen display_poster=q351_6
				la var display_poster "Displayed political support past yr"
			gen express_support=q351_7
				la var express_support "Expressed political support social media past yr"
			gen attend_protest=q351_8
				la var attend_protest "Attended protest past yr"
			gen sign_petition=q351_9
				la var sign_petition "Signed petition past yr"

			foreach x of varlist attend_rally volunteer donate_money member_group contact_official display_poster express_support attend_protest sign_petition {
				destring `x', replace
				la val `x' yes_no
			}

			
				* IDEOLOGICAL SELF-PLACEMENT
			
				gen lib_scale=q42_1
				destring lib_scale, replace
				la def lib_scale 1 "Extremely liberal" 2 "Liberal" 3 "Slightly liberal" 4 "Moderate" 5 "Slightly conservative" 6 "Conservative" 7 "Extremely conservative"		
				la val lib_scale lib_scale
				la var lib_scale "Liberal-Conservative 7pt scale"
				
				gen ideoextreme=abs(lib_scale-4)
				lab var ideoextreme "Extremity of Ideological Self-Placement"
				
				
			 * PARTISAN IDENTITY 
			
				
			destring q43, gen(partisan)
			lab def partisan 1 "Republican" 2 "Democrat" 3 "Independent" 4 "Other"
			lab val partisan partisan
			lab var partisan "Partisanship"
			
			gen partisan_other=q43_4_text
			
			destring q51, gen(lean)
			lab def lean 1 "Republican" 2 "Democrat"
			lab val lean lean 
			lab var lean "Lean Partisanship"
			
			gen republican=(q43=="1") if q43!=""
				la var republican "PartyID Republican"
			
			gen democrat=(q43=="2") if q43!=""
				la var democrat "PartyID Democrat"
			
			gen democrat_lean=democrat
				replace democrat_lean=1 if q51=="1"
				la var democrat_lean "PartyID Lean Democrat"

			gen republican_lean=republican
				replace republican_lean=1 if q51=="2"
				la var republican_lean "PartyID Lean Republican"
			
			gen inparty_image=q63_1
				la var inparty_image "PartyID important self-image"
			
			gen inparty_feel=q63_2
				la var inparty_feel "PartyID unimportant self-esteem"
			
			gen inparty_reflection=q63_3
				la var inparty_reflection "PartyID important reflection of self" 
			
			gen inparty_sense=q63_4
				la var inparty_sense "PartyID unimportant to self-concept"
			
			foreach x of varlist inparty_image inparty_feel inparty_reflection inparty_sense {
				destring `x', replace
				la val `x' agree_disagree
			}
			
			gen inparty_feel_rec=8-inparty_feel
				la val inparty_feel_rec agree_disagree_rec
				la var inparty_feel_rec "Rec partyID unimportant self-esteem"
			
			gen inparty_sense_rec=8-inparty_sense
				la val inparty_sense_rec agree_disagree_rec
				la var inparty_sense_rec "Rec partyID unimportant to self-concept"

			
			gen inparty_overlap=q173
				destring inparty_overlap, replace
				la var inparty_overlap "PartyID self-group overlap graphic"
			
			gen inparty_we=q72
				destring inparty_we, replace
				replace inparty_we=inparty_we-3
				la var inparty_we "PartyID We-They freq."
				la val inparty_we always_never
				
			gen inparty_we_rec = 5-inparty_we
				la val inparty_we_rec always_never_rec
				la var inparty_we_rec "Rec partyID We-They freq."	
				
				
			 * POLICY POSITIONS 
			
			 * IMMIGRATION 
				
			gen policy_imm_view=q142
				destring policy_imm_view, replace
				la def policy_imm_view 1 "Decreased a lot" 2 "Decreased a little" 3 "left the same" 4 "Increased a little" 5 "Increased a lot" 
				la val policy_imm_view policy_imm_view
				la var policy_imm_view "Imm policy view"
				
			gen policy_imm_imp=q143
				destring policy_imm_imp, replace
				la val policy_imm_imp important_unimportant
				la var policy_imm_imp "Imm policy importance"
	
			gen policy_imm_vote=q144
				destring policy_imm_vote, replace
				la val policy_imm_vote yes_no_maybe2
				/*
			*combines maybe with no
			gen policy_imm_vote_yes=(q144=="1") if q144!=""
				la val policy_imm_vote_yes yes_no
			*combines maybe with yes
			gen policy_imm_vote_yes_maybe=(q144=="1" | q144=="2") if q144!=""
				la val policy_imm_vote_yes_maybe yes_no_maybe
				la var policy_imm_vote_yes_maybe "Imm dealbreaker for vote"
			*gen policy_imm_vote_no=(q144=="3") if q144!=""
				*la var policy_imm_vote_no "Imm dealbreaker for vote01"
				*/
			gen policy_imm_inparty=q145
				destring policy_imm_inparty, replace
				la var policy_imm_inparty "Imm inparty /10 agree"
			
			gen policy_imm_outparty=q146
				destring policy_imm_outparty, replace
				la var policy_imm_outparty "Imm outparty /10 agree"
				
			 * HEALTHCARE
			
			gen policy_health_view=q147
				destring policy_health_view, replace
				la val policy_health_view support_oppose
				la var policy_health_view "Health policy view"
			
			gen policy_health_imp=q148
				destring policy_health_imp, replace
				la val policy_health_imp important_unimportant
				la var policy_health_imp "Health policy importance"
			
			gen policy_health_vote=q149
				destring policy_health_vote, replace
				la val policy_health_vote yes_no_maybe2

			gen policy_health_inparty=q150
				destring policy_health_inparty, replace
				la var policy_health_inparty "Health inparty /10 agree"
			
			gen policy_health_outparty=q151
				destring policy_health_outparty, replace
				la var policy_health_outparty "Health outparty /10 agree"
				
				 * ABORTION 
			
			gen policy_abort_view=q152
				destring policy_abort_view, replace
				la def policy_abort_view 1 "Never permit" 2 "Permit when abuse" 3 "Permit more than when just abuse" 4 "Always permit" 
				la val policy_abort_view policy_abort_view
				la var policy_abort_view "Abort policy view"
			
			gen policy_abort_imp=q153
				destring policy_abort_imp, replace
				la val policy_abort_imp important_unimportant
				la var policy_abort_imp "Abort policy importance"

			gen policy_abort_vote=q154
				destring policy_abort_vote, replace
				la val policy_abort_vote yes_no_maybe2

			gen policy_abort_inparty=q155
				destring policy_abort_inparty, replace
				la var policy_abort_inparty "Abort inparty /10 agree"
			
			gen policy_abort_outparty=q156
				destring policy_abort_outparty, replace
				la var policy_abort_outparty "Abort outparty /10 agree"
				
				* DEFICIT
			
			gen policy_deficit_view=q157
				destring policy_deficit_view, replace
				la def policy_deficit_view 1 "Reduce deficit much more imp" 2 "Reduce deficit little more imp" 3 "Both equally imp" 4 "Reduce unemployment little more imp" 5 "Reduce unemployment much more imp"
				la val policy_deficit_view policy_deficit_view
				la var policy_deficit_view "Deficit policy view"
			
			gen policy_deficit_imp=q158
				destring policy_deficit_imp, replace
				la val policy_deficit_imp important_unimportant
				la var policy_deficit_imp "Deficit policy importance"
			
			*gen policy_deficit_vote_yes=(q159=="1") if q159!=""
				*la val policy_deficit_vote_yes yes_no

			gen policy_deficit_vote=q159
				destring policy_deficit_vote, replace
				la val policy_deficit_vote yes_no_maybe2
			
	
			gen policy_deficit_inparty=q160
				destring policy_deficit_inparty, replace
				la var policy_deficit_inparty "Deficit inparty /10 agree"
			
			gen policy_deficit_outparty=q161
				destring policy_deficit_outparty, replace
				la var policy_deficit_outparty "Deficit outparty /10 agree"
				
				* GUNS
			
			gen policy_guns_view=q162
				destring policy_guns_view, replace
				la def policy_guns_view 1 "A lot easier to buy" 2 "A little easier to buy" 3 "Keep rules about same" 4 "Little more difficult to buy" 5 "A lot more difficult to buy" 
				la val policy_guns_view policy_guns_view
				la var policy_guns_view "Guns policy view"
			
			gen policy_guns_imp=q163
				destring policy_guns_imp, replace
				la val policy_guns_imp important_unimportant
				la var policy_guns_imp "Gun policy importance"

			gen policy_guns_vote=q164
				destring policy_guns_vote, replace
				la val policy_guns_vote yes_no_maybe2

			gen policy_guns_inparty=q165
				destring policy_guns_inparty, replace
				la var policy_guns_inparty "Guns inparty /10 agree"
			
			gen policy_guns_outparty=q166
				destring policy_guns_outparty, replace
				la var policy_guns_outparty "Guns outparty /10 agree"
				
				 * PROPENSITY TO MORALIZE 
			
			gen policy_imm_moral=q138_1
				la var policy_imm_moral "Imm part moral code"
			gen policy_health_moral=q138_2
				la var policy_health_moral "Health part moral code"
			gen policy_abort_moral=q138_3
				la var policy_abort_moral "Abort part moral code"
			gen policy_deficit_moral=q138_5
				la var policy_deficit_moral "Deficit part moral code"
			gen policy_guns_moral=q138_4
				la var policy_guns_moral "Guns part moral code"
			
			foreach x of varlist policy_imm_moral policy_health_moral policy_abort_moral policy_guns_moral policy_deficit_moral {
				destring `x', replace
				la val `x' not_very
			}
			
				* POLITICAL VALUES 
				
			gen inparty_therm=q71_1
				destring inparty_therm, replace
				la var inparty_therm "Inparty thermometer"
				
			gen outparty_therm=q71_2
				destring outparty_therm, replace
				la var outparty_therm "Outparty thermometer"

			gen outparty_therm_rev = 100-outparty_therm
				la var outparty_therm_rev "Outparty thermometer (reverse-coded)"

			gen inparty_for=(q73=="1") if q73!=""
				la var inparty_for "PartyID for inparty"
			gen outparty_against=(q73=="4") if q73!=""
				la var outparty_against "PartyID against outparty"
			
			
			gen inparty_patriotic=q75_1
				la var inparty_patriotic "Inparty patriotic"
			gen inparty_intelligent=q75_2
				la var inparty_intelligent "Inparty intelligent"
			gen inparty_honest=q75_3
				la var inparty_honest "Inparty honest"
			gen inparty_open=q75_4
				la var inparty_open "Inparty open-minded"
			gen inparty_generous=q75_5
				la var inparty_generous "Inparty generous"
			gen inparty_hypocrite=q75_6
				la var inparty_hypocrite "Inparty hypocritical"
			gen inparty_selfish=q75_7
				la var inparty_selfish "Inparty selfish"
			gen inparty_mean=q75_8
				la var inparty_mean "Inparty mean"
			
			
			foreach x of varlist inparty_patriotic inparty_intelligent inparty_honest inparty_open inparty_generous inparty_hypocrite inparty_selfish inparty_mean {
				destring `x', replace
				la val `x' applies
			}
			
			foreach x of varlist inparty_hypocrite inparty_selfish inparty_mean {
				gen `x'_rec=4-`x'
				la val `x'_rec applies_rec
			}
	
				la var inparty_hypocrite_rec "Rec inparty hypocritical"
				la var inparty_selfish_rec "Rec inparty selfish"
				la var inparty_mean_rec "Rec inparty mean"
			
			gen inparty_thought = q169_1
				la var inparty_thought "Inparty capacity complex thought" 
			gen inparty_sensations = q169_2
				la var inparty_sensations "Inparty capacity basic sensations"
			gen inparty_love = q169_3
				la var inparty_love "Inparty capacity love & compassion"
			gen inparty_anger = q169_4
				la var inparty_anger "Inparty capacity anger & hatred"
			
			
			foreach x of varlist inparty_thought inparty_sensations inparty_love inparty_anger {
				destring `x', replace
				la val `x' capable_incapable
			}
			
			gen inparty_trust = q76
				destring inparty_trust, replace
				la val inparty_trust always_never_alt
				la var inparty_trust "Inparty trust to do right for US"
			
			gen outparty_view = q137_1
				destring outparty_view, replace
				la val outparty_view not_well
				la var outparty_view "Outparty view hard to see"
			
			gen outparty_view_rec = 6-outparty_view
				la val outparty_view_rec not_well_rec
				la var outparty_view_rec "Rec outparty view hard to see"
			
			
			gen outparty_perspective = q137_2
				destring outparty_perspective, replace
				la val outparty_perspective not_well
				la var outparty_perspective "Outparty perspective try to see"
			
			
			gen outparty_friends = q77
				la var outparty_friends "Comfort close friends outparty"
			
			gen outparty_neigh = q78
				la var outparty_neigh "Comfort neighbors outparty"
			
			gen outparty_marry = q79
				la var outparty_marry "Comfort friend marry outparty"
			
			foreach x of varlist outparty_friends outparty_neigh outparty_marry {
				destring `x', replace
				la val `x' comfortable_uncomfortable
			}
			 
				alpha outparty_friends outparty_neigh outparty_marry, std item detail gen(comfort_index)
					la var comfort_index "Outparty comfort index"

			gen outparty_patriotic=q710_1
				la var outparty_patriotic "Outparty patriotic"
			gen outparty_intelligent=q710_2
				la var outparty_intelligent "Outparty intelligent"
			gen outparty_honest=q710_3
				la var outparty_honest "Outparty honest"
			gen outparty_open=q710_4
				la var outparty_open "Outparty open-minded"
			gen outparty_generous=q710_5
				la var outparty_generous "Outparty generous"
			gen outparty_hypocrite=q710_6
				la var outparty_hypocrite "Outparty hypocritical"
			gen outparty_selfish=q710_7
				la var outparty_selfish "Outparty selfish"
			gen outparty_mean=q710_8
				la var outparty_mean "Outparty mean"
			
			foreach x of varlist outparty_patriotic outparty_intelligent outparty_honest outparty_open outparty_generous outparty_hypocrite outparty_selfish outparty_mean {
				destring `x', replace
				la val `x' applies
			}
			
			foreach x of varlist outparty_hypocrite outparty_selfish outparty_mean {
				gen `x'_rec=4-`x'
				la val `x'_rec applies_rec
			}
			
				la var outparty_hypocrite_rec "Rec outparty hypocritical"
				la var outparty_selfish_rec "Rec outparty selfish"
				la var outparty_mean_rec "Rec outparty mean"
			
			gen outparty_thought = q170_1
				la var outparty_thought "Outparty capacity complex thought" 
			gen outparty_sensations = q170_2
				la var outparty_sensations "Outparty capacity basic sensations"
			gen outparty_love = q170_3
				la var outparty_love "Outparty capacity love & compassion"
			gen outparty_anger = q170_4
				la var outparty_anger "Outparty capacity anger & hatred"
			
			foreach x of varlist outparty_thought outparty_sensations outparty_love outparty_anger {
				destring `x', replace
				la val `x' capable_incapable
			}
			
			gen outparty_trust = q711
				destring outparty_trust, replace
				la val outparty_trust always_never_alt
				la var outparty_trust "Outparty trust to do right for US"
			  
			gen outparty_threat = (q712 == "1") if q712!=""
				la val outparty_threat yes_no
				la var outparty_threat "Outparty threat to US"
				
				
				* SUPPORT FOR CIVIL DISCOURSE
				
			encode q123, gen(sup_cvl_grp)
			recode sup_cvl_grp (1=0)(2 3=1)
			lab var sup_cvl_grp "Interest in Talking to Outparty"
			
			encode q125, gen(sup_cvl_off)
			recode sup_cvl_off (11=3) (12=2)(13=1) (14=0)
			lab var sup_cvl_off "Importance of Inoffensive Language"
		
			
			
				
				* CAPACITY FOR CIVIL DISCOURSE
				
				
			encode q126, gen(cap_cvl_off)
			recode cap_cvl_off (1=3) (2=2)(3=1) (4=0)
			lab var cap_cvl_off "Confident Using  Inoffensive Language"
			
			encode q124, gen(cap_cvl_tlk)
			recode cap_cvl_tlk (1=1)(2=-1)(3=0)
			lab var cap_cvl_tlk "Enjoy Talking to Outparty"

		

				* CROSS PARTY INTERACTIONS
				
			gen outparty_contact = q171
				destring outparty_contact, replace
				replace outparty_contact = outparty_contact-10
				la val outparty_contact frequency
				la var outparty_contact "Outparty freq. interactions"
				
			gen outparty_talk = q174
				destring outparty_talk, replace
				replace outparty_talk = outparty_talk-64
				la val outparty_talk frequency
				la var outparty_talk "Outparty freq. talk politics"
				
			gen inparty_closefriends = q122_1
				destring inparty_closefriends, replace
				la val inparty_closefriends none_all
				la var inparty_closefriends "Close friends inparty"
				
			gen outparty_closefriends = q122_2
				destring outparty_closefriends, replace
				la val outparty_closefriends none_all
				la var outparty_closefriends "Close friends outparty"
				
			gen indep_closefriends = q122_3
				destring indep_closefriends, replace
				la val indep_closefriends none_all
				la var indep_closefriends "Close friends independents"
				
			gen pricon_frnd_diff = outparty_closefriends + indep_closefriends - inparty_closefriends
			la var pricon_frnd_diff "Outgroup Oriented Friend Group"

				 * DEMOGRAPHICS 

			gen woman = (q212=="1") if q212!=""
				lab def woman 0 "Male/other" 1 "Female"
				lab val woman woman
				lab var woman "Woman"

				split q213, parse(",") gen(q213) destring
			gen white = (q2131 == 1) if q2131!=.
				replace white = 1 if q2132==1
				replace white = 1 if q2133==1
				la var white "White"
			
			gen asian = (q2131 == 5) if q2131!=.
				replace asian = 1 if q2132==5
				replace asian = 1 if q2133==5
				la var asian "Asian"
			
			drop q2131 q2132 q2133
			
			gen citizen = (q131=="1" | q131=="2") if q131!=""
				 la val citizen yes_no
				 la var citizen "Citizenship"
				 
*We want to drop non-citizens, right?
				 drop if citizen==0
				 
			gen empathy_twosides = q136_1
				la var empathy_twosides "Gen empathy see two sides"
			gen empathy_sorry = q136_2	
				la var empathy_sorry "Gen empathy don't feel sry"
			gen empathy_listen = q136_3
				la var empathy_listen "Gen empathy don't listen"
			gen empathy_feelings = q136_4
				la var empathy_feelings "Gen empathy concern feelings"
			gen empathy_imagine = q136_5
				la var empathy_imagine "Gen empathy imagine others' shoes"
			
			foreach x of varlist empathy_twosides empathy_sorry empathy_listen empathy_feelings empathy_imagine {
				destring `x', replace
				la val `x' not_well
			}
			
			foreach x of varlist empathy_sorry empathy_listen {
				gen `x'_rec = 6-`x'
				la val `x'_rec not_well_rec
			}	
				la var empathy_sorry_rec "Rec gen empathy don't feel sry"
				la var empathy_listen_rec "Rec gen empathy don't listen"



	
/* VAR & INDEX CONSTRUCTION */
					
			* Generate political engagement index
				alpha talk_politics plan_vote attend_rally volunteer donate_money member_group contact_official display_poster express_support attend_protest sign_petition, std item detail gen(idx_pol_engage)
					la var idx_pol_engage "Political engagement index"
				
			* Generate ingroup identity salience indexes
			
				alpha inparty_image inparty_feel_rec inparty_reflection inparty_sense_rec inparty_overlap inparty_we_rec, std item detail gen(idx_ingroup_salience)
					la var idx_ingroup_salience "Ingroup identity salience index"
				
						* Generate individual ideological polarization measure 1 (issue constraint)
			
			*% left leaning
			foreach v in policy_imm_view policy_health_view  policy_deficit_view policy_guns_view {
			recode `v' (4 5=1)(1 2 3=0), gen(L_`v')
			}
			recode policy_abort_view (3 4=1)(1 2 =0), gen(L_policy_abort_view)
			egen leftpolicy=rowmean(L_policy*)
			*% right leaning
			foreach v in policy_imm_view policy_health_view  policy_deficit_view policy_guns_view {
			recode `v' (1 2=1)(4 5 3=0), gen(R_`v')
			}
			recode policy_abort_view (1 2=1)(3 4 =0), gen(R_policy_abort_view)
			egen rightpolicy=rowmean(R_policy*)
			* difference (constraint)
			gen ind_ideo_con=abs(leftpolicy-rightpolicy)
			la var ind_ideo_con "Individual ideological constraint index"
			drop L_* R_* leftpolicy rightpolicy  
			
			* Generate individual ideological polarization measure 2 (issue extremity) -- code from Mason (2018) -- footnote to thank
			* extremity
			foreach v in policy_imm_view policy_health_view  policy_deficit_view policy_guns_view {
			recode `v' (5=1)(4=2), gen(ex`v')
			replace ex`v'=(1-((ex`v'-1)/2))
			}
			recode policy_abort_view (1 4=1)(2=3) (3=2), gen(expolicy_abort_view)
			replace expolicy_abort_view=(1-((expolicy_abort_view-1)/2))
			* importance 
			foreach v in policy_imm_ policy_health_ policy_abort_ policy_deficit_ policy_guns_ {
			replace `v'imp=(`v'imp-1)/3
			}
			* weight extremity by importance
			foreach v in policy_imm_ policy_health_ policy_abort_ policy_deficit_ policy_guns_ {
			gen `v'ext=ex`v'view * `v'imp
			}
			alpha policy_imm_ext policy_health_ext policy_abort_ext policy_deficit_ext policy_guns_ext, gen(ind_ideo_ext) 
			la var ind_ideo_ext "Individual ideological extremity index"
				
			* Generate perceived mass ideological polarization index
			
								
				foreach x in imm health abort deficit guns {
					gen policy_`x'_mass_pol = policy_`x'_inparty - policy_`x'_outparty
				}
						la var policy_imm_mass_pol "Imm perceived mass polarization"
						la var policy_health_mass_pol "Health perceived mass polarizaiton"
						la var policy_abort_mass_pol "Abort perceived mass polarization"
						la var policy_deficit_mass_pol "Deficit perceived mass polarization"
						la var policy_guns_mass_pol "Guns perceived mass polarization"
				
				alpha *_mass_pol, std item detail gen(idx_mass_ideo_pol)
					la var idx_mass_ideo_pol "Perceived mass ideological polarization index"
				
			* Generate affective polarization index

				* Generate inparty vs. outparty feeling thermometer

					gen therm_diff = inparty_therm - outparty_therm
						la var therm_diff "Thermometer difference"
				
				* Generate inparty vs. outparty trust score
					
					gen trust_diff = inparty_trust - outparty_trust				
						la var trust_diff "In-Out trust difference"

				alpha therm_diff outparty_against trust_diff outparty_friends outparty_neigh outparty_marry outparty_threat, std item detail gen(idx_affect_pol)
					la var idx_affect_pol "Affective polarization index"
	
				alpha therm_diff trust_diff outparty_friends outparty_neigh outparty_marry outparty_threat, std item detail gen(idx_affect_pol_noneg)
					la var idx_affect_pol_noneg "Affective polarization index (no negative partisanship)"

				alpha therm_diff trust_diff comfort_index outparty_threat, std item detail gen(idx_affect_pol_noneg_comf)
					la var idx_affect_pol_noneg_comf "Affective polarization index (no negative partisanship, outparty comfort index)"
	
				alpha outparty_therm outparty_trust outparty_friends outparty_neigh outparty_marry outparty_threat, std item detail gen(idx_affect_pol_noneg_out)
					la var idx_affect_pol_noneg_out "Affective polarization index (no negative partisanship, outparty animus only)"
	
			* Generate stereotyping index
			
				* Generate inparty and outparty stereotyping indexes
		
					gen inparty_stereo_pos = inparty_patriotic + inparty_intelligent + inparty_honest + inparty_open + inparty_generous
						la var inparty_stereo_pos "Inparty pos. stereotyping"
					
					gen inparty_stereo_neg = inparty_hypocrite + inparty_selfish + inparty_mean
						la var inparty_stereo_neg "Inparty neg. stereotyping"
					
					gen inparty_stereo_all = inparty_patriotic + inparty_intelligent + inparty_honest + inparty_open + inparty_generous + inparty_hypocrite_rec + inparty_selfish_rec + inparty_mean_rec
						la var inparty_stereo_all "Inparty stereotyping index"
					
					gen outparty_stereo_pos = outparty_patriotic + outparty_intelligent + outparty_honest + outparty_open + outparty_generous
						la var outparty_stereo_pos "Outparty pos. stereotyping"
					
					gen outparty_stereo_neg = outparty_hypocrite + outparty_selfish + outparty_mean
						la var outparty_stereo_neg "Outparty neg. stereotyping"
						
					gen outparty_stereo_all = outparty_patriotic + outparty_intelligent + outparty_honest + outparty_open + outparty_generous + outparty_hypocrite_rec + outparty_selfish_rec + outparty_mean_rec
						la var outparty_stereo_all "Outparty stereotyping index"

					
				gen stereo_diff = inparty_stereo_all - outparty_stereo_all
					la var stereo_diff "In-Out stereotyping index"
					
			* Generate humanization index
			
				* Generate inparty and outparty humanization indexes
		
					gen inparty_human = inparty_thought + inparty_sensations + inparty_love + inparty_anger			
						la var inparty_human "Inparty humanization index"
		
					gen outparty_human = outparty_thought + outparty_sensations + outparty_love + outparty_anger			
						la var outparty_human "Outparty humanization index"
					
				gen human_diff = inparty_human - outparty_human					
					la var human_diff "In-Out humanization index"
						
			* Generate outparty empathy index
			
				alpha outparty_view_rec outparty_perspective, std item detail gen(idx_outgroup_empathy)					
					la var idx_outgroup_empathy "Outgroup empathy index"			
				
						
			* Generate support for civil discourse index
			
				alpha sup_cvl_grp sup_cvl_off, std item detail gen(idx_civil_support)
					la var idx_civil_support "Support for civil discourse index"	
					
			* Generate capacity for civil discourse index
			
				alpha cap_cvl_tlk cap_cvl_off, std item detail gen(idx_civil_capacity)
					la var idx_civil_capacity "Capacity for civil discourse index"
						
			* Generate moralization index
			
				alpha policy_imm_moral policy_health_moral policy_abort_moral policy_guns_moral policy_deficit_moral, std item detail gen(idx_moralization)					
					la var idx_moralization "Moralization of politics index"	
			
			* Generate outparty contact index
			
				alpha outparty_contact outparty_talk pricon_frnd_diff, std item detail gen(idx_outparty_contact)				
					la var idx_outparty_contact "Outparty contact index"				
				
		
			* Generate general empathy index

				alpha empathy_twosides empathy_sorry_rec empathy_listen_rec empathy_feelings empathy_imagine, std item detail gen(idx_empathy)					
					la var idx_empathy "General empathy index"		

				
		
/* SAVE */
				
			placevar campus party inparty outparty sid, before(finished)
				
			gen END=.
			
			foreach x of varlist q32 - END {
				ren `x' b_`x'
			}
			
			drop b_END
			
			gen IDENTIFIERS=.
				la var IDENTIFIERS "=============================="
			
			gen RAW_VARS=.
				la var RAW_VARS "=============================="
			
			gen CLEAN_VARS=.
				la var CLEAN_VARS "=============================="

			gen CONSTRUCTED_VARS=.
				la var CONSTRUCTED_VARS "=============================="


			placevar IDENTIFIERS, before(campus)

			placevar RAW_VARS, before(b_q32)
			
			placevar CLEAN_VARS, before(b_talk_politics)
	
			placevar CONSTRUCTED_VARS, before(b_idx_pol_engage)
											
			sort sid
			drop if sid==.
			
				
			save "baseline_clean_all.dta", replace
	

	
